-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#13227] Improve testing docs #13242
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I think it definitely improves the experience for a developer that wants to contribute via test cases. Great work!
- It aims to ensure all components of the application work as expected, assuming its dependencies are working. | ||
- This is done in TEAMMATES by using mocks to simulate a component's dependencies. | ||
|
||
Frontend Unit tests in TEAMMATES are located in `.spec.ts` files, while Backend Unit tests in TEAMMATES can be found in the package `teammates.test`. | ||
Frontend unit tests in TEAMMATES are located in `*.spec.ts` files and configured in `src/web/jest.config.js`. | ||
|
||
Backend unit tests in TEAMMATES are located in the package `teammates.test` and configured in `src/test/resources/testng-component.xml`. | ||
|
||
## Writing Unit Tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it looks fine.
Just a note—I typically run tests using IntelliJ’s built-in features rather than executing them manually using the terminal. In the test file, I just click the green test button and a task window pops up. In the task window, I will then select to run unitTests
, since we’ve only been working with unit tests. The screenshot of the intellij window pop-up is attached below:
Would it be helpful to add comments for developers who primarily use IDE features? Maybe we could include guidance for popular IDEs like VS Code and IntelliJ.
|
||
</div> | ||
- **Performance tests**: Evaluate the application's stability and responsiveness under expected, peak, and prolonged loads. See [Performance Testing](performance-testing.md). | ||
- **Accessibility tests**: Ensure the application is accessible to users with disabilities. See [Accessibility Testing](axe-testing.md). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be good to also mention that docker has to be running to do testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, great job on the improvements for the docs and the changes are very much welcomed!
npm run test | ||
``` | ||
|
||
Most frontend component tests use [Snapshot Testing](snapshot-testing.md). To update snapshots, run the following command: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's useful to show that we need to run npm run test
for Snapshot Testing. However, I think it would also be great if you could add a hyperlink in snapshot-testing.md
in the "How do we use Snapshot Testing?" section to this part, or perhaps you can add instructions there on which commands we could use. It's a little confusing to newer developers because the given Jest docs link shows a different command (jest --updateSnapshot
).
On a side note, it would help me greatly as well since I haven't found the right way to do so with my button PR 🤣
|
||
Test suite | Command | Results can be viewed in | ||
---|---|--- | ||
`Component tests` | `./gradlew componentTests --continue` | `{project folder}/build/reports/tests/componentTests/index.html` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be useful to include a rough approximation of how long the tests will take to run (not just for this but for frontend as well)? I believe some of the tests takes ages to run and it might catch new developers off guard.
@@ -202,5 +248,3 @@ account.setEmail("[email protected]"); | |||
Student student = getTypicalStudent(); | |||
student.setName("New Student Name"); | |||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be useful to add some helpful tips if the tests cannot run, for instance, there was a time where I couldn't run my test and I had to do ./gradlew clean build
which then rectified the issue.
Fixes #13227
Outline of Solution